# -*- coding: utf-8 -*-
# @Create_time   : :
# @Author        :kumiler
# @emial         :lukunming@jtexpress.com
# @File          :__init__.py
# @Desc          :

from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from jms.dwd.oms.dwd_yl_oms_oms_waybill_incre_dt import jms_dwd__dwd_yl_oms_oms_waybill_incre_dt
from jms.dwd.tab.dwd_tab_barscan_deliver_base_dt import jms_dwd__dwd_tab_barscan_deliver_base_dt
from jms.dwd.tab.dwd_tab_barscan_send_base_dt import jms_dwd__dwd_tab_barscan_send_base_dt
from jms.dwd.tab.dwd_tab_barscan_arrival_base_dt import jms_dwd__dwd_tab_barscan_arrival_base_dt
from jms.dwd.tab.dwd_tab_barscan_centersend_base_dt import jms_dwd__dwd_tab_barscan_centersend_base_dt
from jms.dwd.tab.dwd_tab_barscan_centerarrival_base_dt import jms_dwd__dwd_tab_barscan_centerarrival_base_dt
from jms.dim.dim_network_whole_massage import jms_dim__dim_network_whole_massage
from jms.time_sensor.time_after_02_00 import time_after_02_00

jms_dws__dws_tbl_site_scan_operation_stat_dt = SparkSqlOperator(
    task_id='jms_dws__dws_tbl_site_scan_operation_stat_dt',
    email=['lukunming@jtexpress.com','yl_etl@yl-scm.com'],
    pool_slots=4,
    master='yarn',
    name='jms_dws__dws_tbl_site_scan_operation_stat_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/dws/dws_tbl_site_scan_operation_stat_dt/execute.sql',
    executor_cores=3,
    executor_memory='6G',
    num_executors=30,
    conf={'spark.dynamicAllocation.enabled'                  : 'true',
          'spark.shuffle.service.enabled'                    : 'true',
          'spark.dynamicAllocation.maxExecutors'             : 40,
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 30,
          'spark.sql.sources.partitionOverwriteMode'         : 'dynamic',
          'spark.executor.memoryOverhead'                    : '1G',
          },
    hiveconf={'hive.exec.dynamic.partition'             : 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode'        : 'nonstrict',
              'hive.exec.max.dynamic.partitions'        : 100,  # 最大分区
              'hive.exec.max.dynamic.partitions.pernode': 100,  # 最大分区
              },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=30),
)

jms_dws__dws_tbl_site_scan_operation_stat_dt << [
    jms_dwd__dwd_yl_oms_oms_waybill_incre_dt,
    jms_dwd__dwd_tab_barscan_deliver_base_dt,
    jms_dwd__dwd_tab_barscan_send_base_dt,
    jms_dwd__dwd_tab_barscan_arrival_base_dt,
    jms_dwd__dwd_tab_barscan_centersend_base_dt,
    jms_dwd__dwd_tab_barscan_centerarrival_base_dt,
    jms_dim__dim_network_whole_massage,

]

jms_dws__dws_tbl_site_scan_operation_stat_dt << time_after_02_00
